package com.lzs.adx.web.modules.adx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.lzs.adx.commmon.service.impl.CrudServiceImpl;
import com.lzs.adx.web.modules.adx.dao.ReportResultDao;
import com.lzs.adx.web.modules.adx.dto.ReportResultDTO;
import com.lzs.adx.web.modules.adx.entity.ReportResultEntity;
import com.lzs.adx.web.modules.adx.entity.ReportTotalEntity;
import com.lzs.adx.web.modules.adx.service.ReportResultService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 
 *
 * @author wangzhijun 825400558@qq.com
 * @since 1.0.0 2023-06-06
 */
@Service
public class ReportResultServiceImpl extends CrudServiceImpl<ReportResultDao, ReportResultEntity, ReportResultDTO> implements ReportResultService {

    @Override
    public QueryWrapper<ReportResultEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        String stime = (String)params.get("stime");
        String etime = (String)params.get("etime");
        String resultType = (String)params.get("resultType");
        String dspId = (String)params.get("dspId");
        String date = (String)params.get("date");


        QueryWrapper<ReportResultEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);
        wrapper.ge(StringUtils.isNotBlank(stime) ,"date",stime);
        wrapper.le(StringUtils.isNotBlank(etime) ,"date",etime);
        wrapper.eq(StringUtils.isNotBlank(resultType) ,"result_type",resultType);
        wrapper.eq(StringUtils.isNotBlank(dspId) ,"dsp_id",dspId);
        wrapper.eq(StringUtils.isNotBlank(date),"date",date);

        wrapper.orderByDesc("date");

        return wrapper;
    }


}